package com.chima.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

import com.chima.dao.TastJobDao;
import com.chima.domain.PageRequestBean;
import com.chima.domain.PageResponseBean;
import com.chima.domain.TastJob;
import com.chima.service.TastJobService;

public class TastJobServiceImp implements TastJobService {
	 private TastJobDao tastJobDao;

	public TastJobDao getTastJobDao() {
		return tastJobDao;
	}

	public void setTastJobDao(TastJobDao tastJobDao) {
		this.tastJobDao = tastJobDao;
	}

	public PageResponseBean TastJobs(PageRequestBean pageRequestBean) {
	
		int firstResult =(pageRequestBean.getPage()-1)*pageRequestBean.getLimit();
		int maxResults =pageRequestBean.getLimit();
		int total = tastJobDao.findByTotalCount(pageRequestBean.getDate(),pageRequestBean.getEmp());
		// 获取分页查询条件
//		DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Job.class);
		DetachedCriteria detachedCriteria = pageRequestBean.getCriteria();// 不一定存在
		List<TastJob> tastJobs = tastJobDao.findByCriteria(detachedCriteria, firstResult, maxResults);
		PageResponseBean pageResponseBean = new PageResponseBean();
		pageResponseBean.setRows(tastJobs);
		pageResponseBean.setTotal(total);
		return pageResponseBean;
	}

	public void saveTastJob(TastJob tastJob) {
	    tastJobDao.save(tastJob);
	}

	public void updateTastJob(TastJob tastJob) {
		tastJobDao.update(tastJob);
	}

	public void deleteTastJob(int id) {
//		tastJobDao.delete(tastJob);
		
	}

	public TastJob findTastJobbyId(int id) {
		
		return tastJobDao.findById(id);
	}
	 

}
